package game.ai.fsm;
import game.objects.npc.FSMNPC;
public class Condition {
	public String name;
	public boolean fulfilled;
	private ConditionHandler condhandler;
	private boolean passcond;
	public Condition(FSMNPC npc, String name, ConditionHandler ch) {
		fulfilled = false;
		passcond = false;
		this.name = name;
		if (ch != null)
			this.condhandler = ch;
		npc.addCondition(this);
	}
	public Condition(FSMNPC npc, String name, boolean pass) {
		this(npc, name, pass ? new PassCondition() : null);
	}
	public Condition() {
		name = "PassCondition";
		passcond = true;
		fulfilled = false;
	}
	public void setFulfilled() {
		fulfilled = true;
	}
	public void check() {
		if (condhandler != null)
			this.fulfilled = condhandler.isFulfilled();
		else {
			if (passcond)
				fulfilled = true;
		}
	}
}
